Skip to content

[6.x] Fix return type error#19079

Draft
brianjhanson wants to merge 2 commits into
6.xfrom
bugfix/datetime-return
Draft

[6.x] Fix return type error#19079
brianjhanson wants to merge 2 commits into
6.xfrom
bugfix/datetime-return

Conversation

@brianjhanson

@brianjhanson brianjhanson commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes a return type error (below) that happened when creating a user via the CLI

   TypeError

  CraftCms\Cms\Support\DateTimeHelper::toDateTime(): Return value must be of type DateTime|false, Carbon\CarbonImmutable returned

  at /tmp/packages/cms/src/Support/DateTimeHelper.php:86
     82▕             return $value;
     83▕         }
     84▕
     85▕         if ($value instanceof DateTimeInterface) {
  ➜  86▕             return Date::instance($value);
     87▕         }
     88▕
     89▕         if (! $value) {
     90▕             return false;

  1   /tmp/packages/cms/src/Element/Operations/ElementWrites.php:973
      CraftCms\Cms\Support\DateTimeHelper::toDateTime()

  2   /tmp/packages/cms/src/Element/Operations/ElementWrites.php:431
      CraftCms\Cms\Element\Operations\ElementWrites::updateModel()

Failed to run artisan craft:users/create: exit status 1

I'm pretty sure this is related to converting all of the date times to Carbon, but I didn't spend much time tracking the reason down.

@brianjhanson brianjhanson changed the title Fix return type error [6.x] Fix return type error Jun 11, 2026
@brianjhanson brianjhanson requested a review from riasvdv June 11, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants